<?php

// Transactie functies
// Handboek PHP
// Arjan Burger

function mysql_start_transaction($connection=FALSE) {

	$sql = "SET AUTOCOMMIT=0;";
	mysql_do_query($sql, $connection);
	$sql = "START TRANSACTION;";
	$result = mysql_do_query($sql, $connection);

	return $result;

}

function mysql_commit($connection=FALSE) {

	$sql = "COMMIT;";
	$result = mysql_do_query($sql, $connection);
	return $result;

}

function mysql_rollback($connection=FALSE) {

	$sql = "ROLLBACK;";
	$result = mysql_do_query($sql, $connection);
	return $result;

}

function mysql_do_query($sql, $connection) {

	// Default connection

	if ($connection == FALSE) {

		$result = @mysql_query($sql) or die ("Kan query niet uitvoeren: " . mysql_error());

	} else {

	// Certain connection

		$result = @mysql_query($sql, $connection) or die ("Kan query niet uitvoeren: " . mysql_error());

	}

	return $result;

}

?>